﻿using System.Collections;
using System.Collections.Generic;

namespace BusinessFramework
{
    public abstract class RecursiveStrategy
    {
        protected abstract IEnumerable<IEntityExtensions> GetSimpleProperties(object target);
        public abstract IEnumerable<IEnumerable> GetCollections(object target);

        public IEnumerable<IEntityExtensions> GetAllChildObjects(object target)
        {
            foreach (var simpleProperty in GetSimpleProperties(target))
                yield return simpleProperty;
            foreach (var element in GetCollectionsElements(target))
                yield return element;
        }

        protected abstract IEnumerable<IEntityExtensions> GetCollectionsElements(object target);
    }
}